<?php
/**
 * Created by PhpStorm.
 * User: WINNERWLY
 * Date: 2018/8/8
 * Time: 14:14
 */

namespace app\index\controller;


use think\Controller;
use think\Db;

class Bill extends Controller
{
    public function index()
    {
        $res = Db::table("bill")
            ->alias('b')
            ->field("b.amount,b.id,b.cooperator_id,b.type,b.status,b.create_time,b.create_user_id,b.remark,c.name as cooperator_name")
            ->join("cooperator c", "b.cooperator_id = c.id", "LEFT")
            ->order("create_time desc")
            ->page(input("page"), input("rows"))
            ->select();

        $total = Db::table("bill")
            ->alias('b')
            ->join("cooperator c", "b.cooperator_id = c.id", "LEFT")
            ->count();

        if ($res) {
            return ajaxReturn(200, "查询成功", $res, $total);
        } else {
            return ajaxReturn(200, "未查询到信息");
        }
    }

}
